package com.elm.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.elm.model.Seller;
import com.elm.model.SellerOrder;
/**
 * 
 * @author pgm
 *
 */
import com.elm.model.ShoppingCar;
import com.elm.service.SellerOrderService;
import com.elm.serviceimpl.SellerOrderServiceImp;
public class OrdersController extends HttpServlet{
	SellerOrderService sorder = new SellerOrderServiceImp();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		HttpSession session=req.getSession();
		Seller seller=(Seller) session.getAttribute("currentSeller");
		List<SellerOrder> sorders2 = new ArrayList<SellerOrder>();
		sorders2 = (List<SellerOrder>) session.getAttribute("sorders2");
		int orderindex = Integer.parseInt(req.getParameter("number"));
		orderindex = orderindex - 1;
		int sorderid = sorders2.get(orderindex).getSellerorderid();
		sorder.updateSellerOrderState(sorderid, 1);
		System.out.println(2323);
		System.out.println(sorderid);
	}
	
}
